<template>
	<view class="relative">
		<u-sticky bg-color="#FFFFFF">
			<view class="px-[16px] py-[8px] border-solid border-0 border-b-[1px] border-[#eeeeee]">
				<view class="text-[14px] text-[#333333]">快递名称：{{logisticsName}}</view>
				<view class="text-[14px] text-[#333333] mt-[10px] flex flex-row items-center">
					<text>快递单号：{{logisticsNo}}</text>
					<u-icon class="ml-[4px]" @click="copy()" name="file-text" size="20"></u-icon>
				</view>
			</view>
		</u-sticky>
		<view class="bg-[#FFFFFF] px-[16px] pb-safe">
			<u-steps direction="column">
				<u-steps-item v-for="(item,index) in dataList" :key="index" :title="item.context" :desc="item.time"></u-steps-item>
			</u-steps>
		</view>
	</view>
</template>

<script setup>
	import {nextTick, ref} from "vue";
	import * as api from "@/api.js";
	import * as uniapp from "@dcloudio/uni-app";
	import {useUserStore} from "@/store/config.js";
	
	const store = useUserStore();
	
	const logisticsNo = ref('');
	const logisticsName = ref('');
	const dataList = ref([]);
	uniapp.onLoad(option => {
		console.log(option);
		logisticsNo.value = option.logisticsNo;
		logisticsName.value = option.logisticsName;
		getLogistics(option.orderId)
	})
	
	const getLogistics = async orderId => {
		uni.showLoading();
		const result = await api.logisticsInfo(store.user.UserID,orderId);
		uni.hideLoading();
		await nextTick();
		if(result[1]) {
			uni.showModal({
				content:result[1],
				showCancel:false,
				success() {
					uni.navigateBack();
				}
			})
		} else {
			dataList.value = result[0];
		}
	}
	
	const copy = () => {
		uni.setClipboardData({
			data:logisticsNo.value,
			success() {
				uni.showToast({
					icon:'success',
					title:'复制成功'
				})
			}
		})
	}
	
</script>

<style>

</style>
